<template>
  <div id="supplementWrapper">
    <el-row>
        <el-col :xs="24" :sm="24" :lg="24" class="primary">质量KPI</el-col>
    </el-row>
    <el-row>
        <el-col :xs="24" :sm="24" :lg="24" class="border"></el-col>
    </el-row>
    <el-row>
      <el-col :xs="24" :sm="24" :lg="24">
        <data-choose dateType="month"></data-choose>
      </el-col>
    </el-row>
    <div class="log" v-show="dataChoose.radio == 2">
      <el-button @click="look" round type="info">查看修改日志</el-button>
    </div>

    <template v-if="dataChoose.radio == 1">
      <el-tabs class="marT" type="border-card" v-model="caName">
        <el-tab-pane label="持续改进积分" name="first">
          <div v-if="caName == 'first'" key="first" id="newimprove" class="supplement-table bgColor marT" style="position: relative;">
            <el-row>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                  <el-table
                    :header-cell-style="{background:'#eef1f6'}"
                    :data="ruleForm.groupImporveData"
                    style="width: 100%">
                      <el-table-column
                            label="持续改进积分"
                            align="center">
                            <el-table-column
                              label="类别"
                              align="center">
                              <template slot-scope="scope">
                                <div>{{ scope.row.types }}</div>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="目标"
                              align="center">
                              <template slot-scope="scope">
                                <div v-if="scope.row.type = 'percent'">
                                  <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                                  <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                                  <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                                  <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                                  <div v-else>={{ scope.row.indicator }}%</div>
                                </div>
                                <div v-else>
                                  <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}</div>
                                  <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}</div>
                                  <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}</div>
                                  <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}</div>
                                  <div v-else>={{ scope.row.indicator }}</div>
                                </div>
                              </template>
                            </el-table-column>

                            <el-table-column
                              label="权重"
                              align="center">
                              <template slot-scope="scope">
                                <div>{{ scope.row.weight }}%</div>
                              </template>
                            </el-table-column>



                            <el-table-column
                              label="实际权重"
                              align="center">
                              <template slot-scope="scope">
                                <div>{{ scope.row.actual_weight }}%</div>
                              </template>
                            </el-table-column>

                            <el-table-column
                              label="计算结果"
                              align="center">
                              <el-table-column
                                label="符合度"
                                align="center"
                                prop="conformity">
                                <template slot-scope="scope">
                                  <el-form-item
                                    v-if="scope.row.status"
                                    :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                    :prop="'groupImporveData.' + scope.$index + '.conformity'"
                                    :rules="ruleForm.rules.percentStr">
                                    <el-input v-model="scope.row.conformity" autocomplete="off"></el-input>
                                  </el-form-item>
                                  <span v-else>{{ scope.row.conformity }}</span>
                                </template>
                              </el-table-column>
                              <el-table-column
                                label="得分"
                                align="center"
                                prop="mark">
                              </el-table-column>
                            </el-table-column>

                            <el-table-column
                              label="备注"
                              align="center">
                              <template slot-scope="scope">
                                <el-input
                                  v-if="scope.row.status"
                                  type="textarea"
                                  placeholder="请输入内容"
                                  v-model="scope.row.comments"
                                  autocomplete="off"
                                  maxlength="2000"
                                  show-word-limit
                                  >
                                </el-input>

                                <span v-else>{{ scope.row.comments }}</span>
                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column fixed="right" align="center" label="操作">
                            <template slot-scope="scope">
                              <div style="margin-bottom: 5px;">
                                <el-button @click="groupChange(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                              </div>

                              <div v-if="scope.row.status" style="margin-bottom: 5px;">
                                <el-button @click="groupCancel(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                              </div>

                              <div>
                                <el-button @click="groupImporveSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                              </div>
                            </template>
                          </el-table-column>
                  </el-table>
                </el-form>
              </el-col>
            </el-row>
          </div>
        </el-tab-pane>
      </el-tabs>
    </template>

    <template v-else>
    <el-tabs ref="myTab" class="marT" type="border-card" v-model="activeName" @tab-click="handleClick"  >
      <el-tab-pane v-if="ruleForm.datas" label="客户满意度管理--客户投诉" name="0">
        <div v-if="activeName == 0" key="sec" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.datas"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                          label="客户满意度管理--客户投诉"
                          align="center">
                          <el-table-column
                            label="类别"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.types }}</div>
                            </template>
                          </el-table-column>
                          <el-table-column
                            label="目标"
                            align="center">
                            <template slot-scope="scope">
                              <div v-if="scope.row.type = 'percent'">
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                              <div v-else>
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="是否启用"
                            align="center">
                            <template slot-scope="scope">
                              <el-select @change="changeTg('datas', scope.$index, scope.row)" :disabled="!scope.row.status" v-model="scope.row.selectStatus" placeholder="是否启用">
                                <el-option
                                  v-for="item in ruleForm.optionsGoal"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="实际权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.actual_weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="审计结果"
                            align="center"
                            class="tablePad"
                            >
                            <el-table-column
                              label=""
                              align="center"
                              width="150"
                              >
                              <template slot-scope="scope">
                                <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                                </div>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label=""
                              align="center"
                              >
                              <template slot-scope="scope">
                                <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                    <el-form-item
                                      v-if="scope.row.status"
                                      :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                      :prop="'datas.' + scope.$index + '.audit_result.'+ item + '.value'"
                                      :rules="ruleForm.rules.number">
                                      <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                      <el-input :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                    </el-form-item>
                                    <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                  </div>
                                </div>

                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="计算结果"
                            align="center">
                            <el-table-column
                              label="符合度"
                              align="center"
                              prop="conformity">
                            </el-table-column>
                            <el-table-column
                              label="得分"
                              align="center"
                              prop="mark">
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="备注"
                            align="center">
                            <template slot-scope="scope">
                              <el-input
                                v-if="scope.row.status"
                                type="textarea"
                                placeholder="请输入内容"
                                :disabled="scope.row.selectStatus == '是' ? false : true"
                                v-model="scope.row.comments"
                                autocomplete="off"
                                maxlength="2000"
                                show-word-limit
                                >
                              </el-input>

                              <span v-else>{{ scope.row.comments }}</span>
                            </template>
                          </el-table-column>
                        </el-table-column>

                        <el-table-column fixed="right" align="center" label="操作">
                          <template slot-scope="scope">
                            <div style="margin-bottom: 5px;">
                              <el-button @click="change(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                            </div>
                            <div v-if="scope.row.status" style="margin-bottom: 5px;">
                              <el-button @click="cancel(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                            </div>
                            <div>
                              <el-button @click="save(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                            </div>
                          </template>
                        </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane v-if="ruleForm.periodDatas" label="阶段点评审" name="1">
        <div v-if="activeName == 1" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.periodDatas"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                          label="阶段点评审"
                          align="center">
                          <el-table-column
                            label="类别"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.types }}</div>
                            </template>
                          </el-table-column>
                          <el-table-column
                            label="目标"
                            align="center">
                            <template slot-scope="scope">
                              <div v-if="scope.row.type = 'percent'">
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 4">={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 5">[-{{ scope.row.indicator }}%, {{scope.row.indicator}}%]</div>
                                <div v-else>(-{{ scope.row.indicator }}%, {{scope.row.indicator}}%)</div>
                              </div>
                              <div v-else>
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 4">={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 5">[-{{ scope.row.indicator }}{{ scope.row.type }}, {{scope.row.indicator}}{{ scope.row.type }}]</div>
                                <div v-else>(-{{ scope.row.indicator }}{{ scope.row.type }}, {{scope.row.indicator}}{{ scope.row.type }})</div>
                              </div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="是否启用"
                            align="center">
                            <template slot-scope="scope">
                              <el-select @change="changeTg('periodDatas', scope.$index, scope.row)" :disabled="!scope.row.status" v-model="scope.row.selectStatus" placeholder="是否启用">
                                <el-option
                                  v-for="item in ruleForm.optionsGoal"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="实际权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.actual_weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="审计结果"
                            align="center"
                            class="tablePad"
                            >
                            <el-table-column
                              label=""
                              align="center"
                              width="150"
                              >
                              <template slot-scope="scope">
                                <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                                </div>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label=""
                              align="center"
                              width="180"
                              >
                              <template slot-scope="scope">
                                <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div v-if="Object.keys(scope.row.audit_result).length > 2">
                                    <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                      <el-date-picker
                                        style="width: 140px;margin: 5px 0;"
                                        v-if="scope.row.status"
                                        value-format="yyyy-MM-dd"
                                        v-model="scope.row.audit_result[item].value"
                                        type="date"
                                        :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)"
                                        placeholder="选择日期">
                                      </el-date-picker>
                                      <span :class="{'red' : scope.row.is_reached === false}" style="height: 23px;display: block;" v-else>{{ scope.row.audit_result[item].value }}</span>
                                    </div>
                                  </div>

                                  <div v-else-if="Object.keys(scope.row.audit_result).length == 2">
                                    <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                      <el-form-item
                                        v-if="scope.row.status"
                                        :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                        :prop="'periodDatas.' + scope.$index + '.audit_result.'+ item + '.value'"
                                        :rules="ruleForm.rules.number">
                                        <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                        <el-input :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                      </el-form-item>
                                      <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                    </div>
                                  </div>

                                  <div v-else>
                                    <el-select :disabled="!scope.row.status || isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" placeholder="请选择">
                                      <el-option
                                        v-for="item in ruleForm.optionsList"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                      </el-option>
                                    </el-select>
                                  </div>

                                </div>
                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="计算结果"
                            align="center">
                            <el-table-column
                              label="符合度"
                              align="center"
                              prop="conformity">
                            </el-table-column>
                            <el-table-column
                              label="得分"
                              align="center"
                              prop="mark">
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="备注"
                            align="center">
                            <template slot-scope="scope">
                              <el-input
                                v-if="scope.row.status"
                                type="textarea"
                                placeholder="请输入内容"
                                :disabled="scope.row.selectStatus == '是' ? false : true"
                                v-model="scope.row.comments"
                                autocomplete="off"
                                maxlength="2000"
                                show-word-limit
                                >
                              </el-input>

                              <span v-else>{{ scope.row.comments }}</span>
                            </template>
                          </el-table-column>
                        </el-table-column>

                        <el-table-column fixed="right" align="center" label="操作">
                          <template slot-scope="scope">
                            <div style="margin-bottom: 5px;">
                              <el-button @click="changePer(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                            </div>
                            <div v-if="scope.row.status" style="margin-bottom: 5px;">
                              <el-button @click="cancelPer(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                            </div>
                            <div>
                              <el-button @click="periodSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                            </div>
                          </template>
                        </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane v-if="ruleForm.bugDatas" label="Bug处理规范" name="2">
        <div v-if="activeName == 2" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.bugDatas"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                          label="Bug处理规范"
                          align="center">
                          <el-table-column
                            label="类别"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.types }}</div>
                            </template>
                          </el-table-column>
                          <el-table-column
                            label="目标"
                            align="center">
                            <template slot-scope="scope">
                              <div v-if="scope.row.type = 'percent'">
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                              <div v-else>
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="是否启用"
                            align="center">
                            <template slot-scope="scope">
                              <el-select @change="changeTg('bugDatas', scope.$index, scope.row)" :disabled="!scope.row.status" v-model="scope.row.selectStatus" placeholder="是否启用">
                                <el-option
                                  v-for="item in ruleForm.optionsGoal"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="实际权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.actual_weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="审计结果"
                            align="center"
                            class="tablePad"
                            >
                            <el-table-column
                              label=""
                              align="center"
                              width="150"
                              >
                              <template slot-scope="scope">
                                <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                                </div>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label=""
                              align="center"
                              >
                              <template slot-scope="scope">
                                <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div v-if="Object.keys(scope.row.audit_result).length >= 2">
                                    <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                      <el-form-item
                                        v-if="scope.row.status"
                                        :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                        :prop="'bugDatas.' + scope.$index + '.audit_result.'+ item + '.value'"
                                        :rules="ruleForm.rules.number">
                                        <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                        <el-input :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                      </el-form-item>
                                      <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                    </div>
                                  </div>

                                  <div v-else>
                                    <el-select :disabled="!scope.row.status || isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" placeholder="请选择">
                                      <el-option
                                        v-for="item in ruleForm.optionsList"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                      </el-option>
                                    </el-select>
                                  </div>
                                </div>
                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="计算结果"
                            align="center">
                            <el-table-column
                              label="符合度"
                              align="center"
                              prop="conformity">
                            </el-table-column>
                            <el-table-column
                              label="得分"
                              align="center"
                              prop="mark">
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="备注"
                            align="center">
                            <template slot-scope="scope">
                              <el-input
                                v-if="scope.row.status"
                                type="textarea"
                                placeholder="请输入内容"
                                :disabled="scope.row.selectStatus == '是' ? false : true"
                                v-model="scope.row.comments"
                                autocomplete="off"
                                maxlength="2000"
                                show-word-limit
                                >
                              </el-input>

                              <span v-else>{{ scope.row.comments }}</span>
                            </template>
                          </el-table-column>
                        </el-table-column>

                        <el-table-column fixed="right" align="center" label="操作">
                          <template slot-scope="scope">
                            <div style="margin-bottom: 5px;">
                              <el-button @click="changeB(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                            </div>
                            <div v-if="scope.row.status" style="margin-bottom: 5px;">
                              <el-button @click="cancelB(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                            </div>
                            <div>
                              <el-button @click="bugSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                            </div>
                          </template>
                        </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane v-if="ruleForm.releaseData" label="版本release" name="3">
        <div v-if="activeName == 3" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.releaseData"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                          label="版本release"
                          align="center">
                          <el-table-column
                            label="类别"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.types }}</div>
                            </template>
                          </el-table-column>
                          <el-table-column
                            label="目标"
                            align="center">
                            <template slot-scope="scope">
                              <div v-if="scope.row.type = 'percent'">
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                              <div v-else>
                                <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}</div>
                                <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}</div>
                                <div v-else>={{ scope.row.indicator }}%</div>
                              </div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="是否启用"
                            align="center">
                            <template slot-scope="scope">
                              <el-select @change="changeTg('releaseData', scope.$index, scope.row)" :disabled="!scope.row.status" v-model="scope.row.selectStatus" placeholder="是否启用">
                                <el-option
                                  v-for="item in ruleForm.optionsGoal"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="实际权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.actual_weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="审计结果"
                            align="center"
                            class="tablePad"
                            >
                            <el-table-column
                              label=""
                              align="center"
                              width="150"
                              >
                              <template slot-scope="scope">
                                <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                                </div>

                              </template>
                            </el-table-column>
                            <el-table-column
                              label=""
                              align="center"
                              >
                              <template slot-scope="scope">
                                <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div v-if="Object.keys(scope.row.audit_result).length >= 2">
                                    <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                      <el-form-item
                                        v-if="scope.row.status"
                                        :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                        :prop="'releaseData.' + scope.$index + '.audit_result.'+ item + '.value'"
                                        :rules="ruleForm.rules.number">
                                        <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                        <el-input :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                      </el-form-item>
                                      <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                    </div>
                                  </div>

                                  <div v-else>
                                    <el-select :disabled="!scope.row.status || isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" placeholder="请选择">
                                      <el-option
                                        v-for="item in ruleForm.optionsList"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                      </el-option>
                                    </el-select>
                                  </div>
                                </div>
                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="计算结果"
                            align="center">
                            <el-table-column
                              label="符合度"
                              align="center"
                              prop="conformity">
                            </el-table-column>
                            <el-table-column
                              label="得分"
                              align="center"
                              prop="mark">
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="备注"
                            align="center">
                            <template slot-scope="scope">
                              <el-input
                                v-if="scope.row.status"
                                type="textarea"
                                placeholder="请输入内容"
                                :disabled="scope.row.selectStatus == '是' ? false : true"
                                v-model="scope.row.comments"
                                autocomplete="off"
                                maxlength="2000"
                                show-word-limit
                                >
                              </el-input>

                              <span v-else>{{ scope.row.comments }}</span>
                            </template>
                          </el-table-column>
                        </el-table-column>

                        <el-table-column fixed="right" align="center" label="操作">
                          <template slot-scope="scope">
                            <div style="margin-bottom: 5px;">
                              <el-button @click="changeR(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                            </div>
                            <div v-if="scope.row.status" style="margin-bottom: 5px;">
                              <el-button @click="cancelR(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                            </div>
                            <div>
                              <el-button @click="releaseSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                            </div>
                          </template>
                        </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane v-if="false" label="持续改进积分" name="4"><!-- ruleForm.imporveData -->
        <div v-if="activeName == 4" id="improve" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.imporveData"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                          label="持续改进积分"
                          align="center">
                          <el-table-column
                            label="类别"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.types }}</div>
                            </template>
                          </el-table-column>
                          <el-table-column
                            label="目标"
                            align="center">
                            <template slot-scope="scope">
                              <div v-if="scope.row.indicator == 0" style="color: red;">未达标</div>
                              <div v-else style="color: green;">达标</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="是否启用"
                            align="center">
                            <template slot-scope="scope">
                              <el-select @change="changeTg('imporveData', scope.$index, scope.row)" :disabled="!scope.row.status" v-model="scope.row.selectStatus" placeholder="是否启用">
                                <el-option
                                  v-for="item in ruleForm.optionsGoal"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="实际权重"
                            align="center">
                            <template slot-scope="scope">
                              <div>{{ scope.row.actual_weight }}%</div>
                            </template>
                          </el-table-column>

                          <el-table-column
                            label="审计结果"
                            align="center"
                            class="tablePad"
                            >
                            <el-table-column
                              label=""
                              align="center"
                              >
                              <template slot-scope="scope">
                                <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                                </div>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label=""
                              align="center"
                              >
                              <template slot-scope="scope">
                                <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                  <div v-if="Object.keys(scope.row.audit_result).length >= 2">
                                    <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                      <el-form-item
                                        v-if="scope.row.status"
                                        :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                        :prop="'imporveData.' + scope.$index + '.audit_result.'+ item + '.value'"
                                        :rules="ruleForm.rules.number">
                                        <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                        <el-input :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                      </el-form-item>
                                      <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                    </div>
                                  </div>

                                  <div v-else>
                                    <el-select :disabled="!scope.row.status || isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)" v-model="scope.row.audit_result[item].value" placeholder="是否达标">
                                      <el-option
                                        v-for="item in ruleForm.optionsReach"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                      </el-option>
                                    </el-select>
                                  </div>
                                </div>
                              </template>
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="计算结果"
                            align="center">
                            <el-table-column
                              label="符合度"
                              align="center"
                              prop="conformity">
                            </el-table-column>
                            <el-table-column
                              label="得分"
                              align="center"
                              prop="mark">
                            </el-table-column>
                          </el-table-column>

                          <el-table-column
                            label="备注"
                            align="center">
                            <template slot-scope="scope">
                              <el-input
                                v-if="scope.row.status"
                                type="textarea"
                                placeholder="请输入内容"
                                :disabled="scope.row.selectStatus == '是' ? false : true"
                                v-model="scope.row.comments"
                                autocomplete="off"
                                maxlength="2000"
                                show-word-limit
                                >
                              </el-input>

                              <span v-else>{{ scope.row.comments }}</span>
                            </template>
                          </el-table-column>
                        </el-table-column>

                        <el-table-column fixed="right" align="center" label="操作">
                          <template slot-scope="scope">
                            <div style="margin-bottom: 5px;">
                              <el-button @click="changeI(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                            </div>

                            <div v-if="scope.row.status" style="margin-bottom: 5px;">
                              <el-button @click="cancelI(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                            </div>

                            <div>
                              <el-button @click="imporveSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                            </div>
                          </template>
                        </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane label="减分项" name="5">
        <div v-if="activeName == 5" id="point" class="supplement-table bgColor marT" style="position: relative;">
          <el-row>
            <el-col :xs="24" :sm="24" :lg="24">
              <el-form :model="ruleForm" :rules="ruleForm.rules" ref="ruleForm">
                <el-table
                  :header-cell-style="{background:'#eef1f6'}"
                  :data="ruleForm.pointDatas"
                  style="width: 100%"
                  :row-class-name="tableRowClassName">
                    <el-table-column
                      label="减分项"
                      align="center">
                      <el-table-column
                        label="类别"
                        align="center"
                        prop="types">

                      </el-table-column>
                      <el-table-column
                        label="目标"
                        align="center"
                        prop="indicator">
                        <template slot-scope="scope">
                          <div v-if="scope.row.type == '次'">
                            <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}次</div>
                            <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}次</div>
                            <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}次</div>
                            <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}次</div>
                            <div v-else>={{ scope.row.indicator }}次</div>
                          </div>
                          <div v-else>
                            <div v-if="scope.row.operator == 0">>{{ scope.row.indicator }}%</div>
                            <div v-else-if="scope.row.operator == 1"><{{ scope.row.indicator }}%</div>
                            <div v-else-if="scope.row.operator == 2">>={{ scope.row.indicator }}%</div>
                            <div v-else-if="scope.row.operator == 3"><={{ scope.row.indicator }}%</div>
                            <div v-else>={{ scope.row.indicator }}%</div>
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="实际"
                        align="center"
                        prop="conformity">
                          <template slot-scope="scope">
                            <div v-if="!scope.row.audit_result">
                              <el-form-item
                                v-if="scope.row.status"
                                :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                :prop="'pointDatas.' + scope.$index + '.conformity'"
                                :rules="scope.row.type == 'percent' ? ruleForm.rules.percentStr : ruleForm.rules.str">
                                <el-input :disabled="scope.row.is_disable === true" v-model="scope.row.conformity" autocomplete="off"></el-input>
                              </el-form-item>
                              <div v-else :class="{'red': scope.row.is_reached === false}">
                                <span v-if="scope.row.type == 'percent'">{{ scope.row.conformity }}%</span>
                                <span v-else>{{ scope.row.conformity }}次</span>
                              </div>
                            </div>
                          </template>
                      </el-table-column>

                      <el-table-column
                        label="审计结果"
                        align="center"
                        class="tablePad"
                        >
                        <el-table-column
                          label=""
                          align="center"
                          >
                          <template slot-scope="scope">
                            <div v-if="scope.row.audit_result">
                              <div :key="item" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">{{ scope.row.audit_result[item].label }}</div>
                              </div>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column
                          label=""
                          align="center"
                          >
                          <template slot-scope="scope">
                            <div v-if="scope.row.audit_result">
                              <div :key="index" v-for="(item, index) in Object.keys(scope.row.audit_result)">
                                <div v-if="Object.keys(scope.row.audit_result).length == 2">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                    <el-form-item
                                      v-if="scope.row.status"
                                      :style="error ? 'marginBottom: 30px' : 'marginBottom: 0'"
                                      :prop="'pointDatas.' + scope.$index + '.audit_result.'+ item + '.value'"
                                      :rules="ruleForm.rules.number">
                                      <!-- scope.row.selectStatus == '是' ? false : true || scope.row.audit_result[item].is_disabled -->
                                      <el-input :disabled="scope.row.audit_result[item].is_disabled" v-model="scope.row.audit_result[item].value" autocomplete="off"></el-input>
                                    </el-form-item>
                                    <span :class="{'red' : scope.row.is_reached === false}" v-else>{{ scope.row.audit_result[item].value }}</span>
                                  </div>
                                </div>

                                <div v-else-if="Object.keys(scope.row.audit_result).length > 2">
                                  <div :class="{'borders': index !== Object.keys(scope.row.audit_result).length - 1}">
                                    <el-date-picker
                                      style="width: 140px;margin: 5px 0;"
                                      v-if="scope.row.status"
                                      value-format="yyyy-MM-dd"
                                      v-model="scope.row.audit_result[item].value"
                                      type="date"
                                      :disabled="isDisabled(scope.row.selectStatus, scope.row.audit_result[item].is_disabled)"
                                      placeholder="选择日期">
                                    </el-date-picker>
                                    <span :class="{'red' : scope.row.is_reached === false}" style="height: 23px;display: block;" v-else>{{ scope.row.audit_result[item].value }}</span>
                                  </div>
                                </div>

                                <div v-else>
                                  <el-select :disabled="!scope.row.status || scope.row.audit_result[item].is_disabled" v-model="scope.row.audit_result[item].value" placeholder="请选择">
                                    <el-option
                                      v-for="item in ruleForm.optionsList"
                                      :key="item.value"
                                      :label="item.label"
                                      :value="item.value">
                                    </el-option>
                                  </el-select>
                                </div>
                              </div>
                            </div>
                          </template>
                        </el-table-column>
                      </el-table-column>

                      <el-table-column
                        label="计算结果"
                        align="center">
                        <el-table-column
                          label="符合度"
                          align="center"
                          prop="conformity">
                        </el-table-column>
                        <el-table-column
                          label="得分"
                          align="center"
                          prop="mark">
                        </el-table-column>
                      </el-table-column>

                      <el-table-column
                        label="备注"
                        align="center"
                        >
                        <template slot-scope="scope">
                          <el-input
                            v-if="scope.row.status"
                            type="textarea"
                            placeholder="请输入内容"
                            v-model="scope.row.comments"
                            autocomplete="off"
                            maxlength="2000"
                            show-word-limit
                            >
                          </el-input>

                          <span v-else>{{ scope.row.comments }}</span>
                        </template>
                      </el-table-column>
                    </el-table-column>

                    <el-table-column fixed="right" align="center" label="操作">
                      <template slot-scope="scope">
                        <div style="margin-bottom: 5px;">
                          <el-button @click="changeP(scope.row, scope.$index)" size="mini" round type="success">修改</el-button>
                        </div>

                        <div v-if="scope.row.status" style="margin-bottom: 5px;">
                          <el-button @click="cancelP(scope.row, scope.$index)" size="mini" round type="warning">取消</el-button>
                        </div>

                        <div>
                          <el-button @click="pointSave(scope.row, scope.$index)" size="mini" round type="primary" :disabled="error || !scope.row.status">保存</el-button>
                        </div>
                      </template>
                    </el-table-column>
                </el-table>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
    </el-tabs>
    </template>

    <el-dialog width="60%" title="日志记录" :visible.sync="dialogVisible">
      <el-table
        :data="log.slice((logCurrent-1)*logSize,logCurrent*logSize)"
        :header-cell-style="{background:'#eef1f6'}"
        style="width: 100%">
        <el-table-column align="center" prop="username" width="130" label="用户名"></el-table-column>
        <el-table-column align="center" prop="operate_time" width="200" label="操作时间"></el-table-column>
        <el-table-column align="center" prop="operate_log" label="操作日志"></el-table-column>
      </el-table>
      <el-pagination class="marT"
        v-show="logTotal > 10"
        :page-size="logSize"
        background
        @size-change="logSizeChange"
        @current-change="logCurrentChange"
        :current-page="logCurrent"
        layout="prev, pager, next"
        style="text-align: center"
        :total="logTotal">
      </el-pagination>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import DataChoose from '@/views/data/dataChoose'
import { getHeader } from '@/app.config'
import { mapState } from 'vuex'
import { Loading } from 'element-ui'

export default {
  components: {
    DataChoose
  },
  computed: {
    ...mapState({
        dataChoose: state => state.dataChoose,
        entry: state => state.entry
    })
  },
  created() {
    this.init()
    if(this.entry == 0) {
      this.$router.push({
        path: '/'
      })
    }
  },
  watch: {
    dataChoose: {
      handler: function() {
        this.$nextTick(() => {
          if(this.dataChoose.radio == 2) {
            if(this.dataChoose.projectId) {
              this.initData()
            }
          } else {
            if(this.dataChoose.selectId) {
              this.groupInitData()
            }
          }
          // if(this.dataChoose.dataSolveStatus) {
          //   this.activeName = '1'
          // }
        })
      },
      deep: true
    }
  },
  data() {
    var validatePercent = (rule, value, callback) => {
      if (!(/^(\d{1,2}(\.\d{1,5})?|100)$/).test(value)) {
        this.error = true
        callback(new Error('请输入正确的百分数'));
      } else {
        this.error = false
        callback()
      }
    };
    var validateNum = (rule, value, callback) => {
      if(!(/^([1-9]\d*|[0]{1,1})$/).test(value)) {
        this.error = true
        callback(new Error('请输入正整数!'));
      } else {
        this.error = false
        callback()
      }
    };
    var validateStr = (rule, value, callback) => {
      if(!(/(^$)|^([1-9]\d*|[0]{1,1})$/).test(value)) {
        this.error = true
        callback(new Error('请输入正整数!'));
      } else {
        this.error = false
        callback()
      }
    };
    var validatePercentStr = (rule, value, callback) => {
      if (!(/(^$)|^(\d{1,2}(\.\d{1,5})?|100)$/).test(value)) {
        this.error = true
        callback(new Error('请输入正确的百分数'));
      } else {
        this.error = false
        callback()
      }
    };
    return {
      error: false,
      dialogVisible: false,
      log: [],
      yearStatus: 'now',
      logCurrent: 1,
      logSize: 10,
      logTotal: 0,
      sys1: '是',
      sys2: '是',
      sys3: '是',
      activeName: '0',
      caName: 'first',
      success: false,
      newSuccess: false,
      ruleForm: {
        periodDatas: [],
        bugDatas: [],
        point_data: [],
        pointDatas: [],
        datas: [],
        releaseData:[],
        imporveData: [],
        groupImporveData: [],
        optionsList: [
          {
            value: true,
            label: '是'
          },
          {
            value: false,
            label: '否'
          }
        ],
        optionsGoal: [
          {
            value: '是',
            label: '是'
          },
          {
            value: '否',
            label: '否'
          }
        ],
        optionsReach: [
          {
            value: '达标',
            label: '达标'
          },
          {
            value: '未达标',
            label: '未达标'
          }
        ],
        rules: {
          pass: [
            { validator: validatePercent, trigger: 'change' }
          ],
          number: [
            { validator: validateNum, trigger: 'change' }
          ],
          str: [
            { validator: validateStr, trigger: 'change' }
          ],
          percentStr: [
            { validator: validatePercentStr, trigger: 'change' }
          ]
        }
      }
    }
  },
  methods: {
    init(){
        this.activeName=localStorage.getItem("keepAlive")
    },
    handleClick(val){
        let dicts=val;
        localStorage.setItem("keepAlive",dicts.name);
    },
    formatter(num) {
      num ? `${(num * 100).toFixed(2)}%` : '0.00%'
      return num
    },
    tableRowClassName({row, rowIndex}) {
      if(row.selectStatus == '否') {
        return 'disabled-row';
      }
    },
    isDisabled(status, disabled) {
      let statusBool, isDisabledStatus
      status == "是" ? statusBool = false : statusBool = true

      if(disabled == true) {
        return isDisabledStatus = true
      } else {
        if(!statusBool) {
          isDisabledStatus = false
        } else {
          isDisabledStatus = true
        }
        return isDisabledStatus
      }
    },
    logCurrentChange(val) {
      this.logCurrent = val
    },
    logSizeChange(val) {
      this.logSize = val
    },
    reload(active) {
      this.initData(active)
    },
    newReload() {
      this.groupInitData()
    },
    changeTg(type, index, row) {
      this.$set(this.ruleForm[type], index, row)
    },
    save(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}
          Object.keys(row.audit_result).forEach(key => {
            obj[row.indicator_name][key] = row.audit_result[key].value
          })
          obj[row.indicator_name]['selectStatus'] = row.selectStatus
          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)

          row.status = false
          this.$set(this.ruleForm.datas, index, row)

        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    periodSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}

          Object.keys(row.audit_result).forEach(key => {
            obj[row.indicator_name][key] = row.audit_result[key].value
          })
          obj[row.indicator_name]['selectStatus'] = row.selectStatus
          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)

          row.status = false
          this.$set(this.ruleForm.periodDatas, index, row)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    bugSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}

          Object.keys(row.audit_result).forEach(key => {
            obj[row.indicator_name][key] = row.audit_result[key].value
          })
          obj[row.indicator_name]['selectStatus'] = row.selectStatus
          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)

          row.status = false
          this.$set(this.ruleForm.bugDatas, index, row)
          // setTimeout(() => {
          //   this.reload()
          // }, 1000)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    releaseSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}

          Object.keys(row.audit_result).forEach(key => {
            obj[row.indicator_name][key] = row.audit_result[key].value
          })
          obj[row.indicator_name]['selectStatus'] = row.selectStatus
          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)

          row.status = false
          this.$set(this.ruleForm.releaseData, index, row)
          // setTimeout(() => {
          //   this.reload()
          // }, 1000)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    imporveSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}

          Object.keys(row.audit_result).forEach(key => {
            obj[row.indicator_name][key] = row.audit_result[key].value
          })
          obj[row.indicator_name]['selectStatus'] = row.selectStatus
          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)

          row.status = false
          this.$set(this.ruleForm.imporveData, index, row)
          // setTimeout(() => {
          //   this.reload()
          // }, 1000)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    groupImporveSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          // if(row.selectStatus == "是") {
            obj.improve_score = {
              improve_score: row.conformity,
              comments: row.comments
            }
            this.newSubmit(obj, this.dataChoose.time)
          // } else {
          //   obj.improve_score = {}
          //   this.submit(obj, this.dataChoose.time)
          // }

          row.status = false
          this.$set(this.ruleForm.groupImporveData, index, row)
          // setTimeout(() => {
          //   this.newReload()
          // }, 1000)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    pointSave(row, index) {
      let obj = {}
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          obj[row.indicator_name] = {}

          if(row.audit_result) {
            Object.keys(row.audit_result).forEach(key => {
              obj[row.indicator_name][key] = row.audit_result[key].value
            })
          } else {
            obj[row.indicator_name][row.indicator_name] = row.conformity !== '' ? Number(row.conformity) : ''
          }

          obj[row.indicator_name]['comments'] = row.comments
          this.submit(obj, this.dataChoose.time)
          row.status = false
          this.$set(this.ruleForm.pointDatas, index, row)
        } else {
          this.$message({
            showClose: true,
            message: '提交错误!',
            type: 'error'
          })
          return false
        }
      })
    },
    cancelP(row, index) {
      row.status = false
      this.$set(this.ruleForm.pointDatas, index, row)
      this.reload(true)
    },
    cancel(row, index) {
      row.status = false
      this.$set(this.ruleForm.datas, index, row)
      this.reload(true)
    },
    cancelPer(row, index) {
      row.status = false
      this.$set(this.ruleForm.periodDatas, index, row)
      this.reload(true)
    },
    cancelB(row, index) {
      row.status = false
      this.$set(this.ruleForm.bugDatas, index, row)
      this.reload(true)
    },
    cancelR(row, index) {
      row.status = false
      this.$set(this.ruleForm.releaseData, index, row)
      this.reload(true)
    },
    cancelI(row, index) {
      row.status = false
      this.$set(this.ruleForm.imporveData, index, row)
      this.reload(true)
    },
    groupCancel(row, index) {
      row.status = false
      this.$set(this.ruleForm.groupImporveData, index, row)
      this.newReload(true)
    },
    change(row, index) {
      row.status = true
      this.$set(this.ruleForm.datas, index, row)
    },
    changePer(row, index) {
      row.status = true
      this.$set(this.ruleForm.periodDatas, index, row)
    },
    changeB(row, index) {
      row.status = true
      this.$set(this.ruleForm.bugDatas, index, row)
    },
    changeR(row, index) {
      row.status = true
      this.$set(this.ruleForm.releaseData, index, row)
    },
    changeI(row, index) {
      row.status = true
      this.$set(this.ruleForm.imporveData, index, row)
    },
    changeP(row, index) {
      row.status = true
      this.$set(this.ruleForm.pointDatas, index, row)
    },
    groupChange(row, index) {
      row.status = true
      this.$set(this.ruleForm.groupImporveData, index, row)
    },
    // tableCurrentChange(val) {
    //   this.ruleForm.tableCurrent = val
    // },
    // tableSizeChange(val) {
    //   this.ruleForm.tableSize = val
    // },
    look() {
      this.dialogVisible = true
      this.$axios.get(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/record?projectId=${this.dataChoose.projectId}&month=${this.dataChoose.time}`, {headers: getHeader()})
      .then(res => {
        if(res.status === 200) {
          if(res.data.code === 200) {
            this.log = res.data.data
            this.logTotal = this.log.length
            this.logCurrent = 1
          }
        }
      })
    },
    initData(active) {
     
      let loadingInstance = Loading.service({ fullscreen: true, text: '加载中,请稍后...' });
      this.$axios.get(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/data?projectId=${this.dataChoose.projectId}&time=${this.dataChoose.time}`, {headers: getHeader()})
      .then(res => {
        if(res.status === 200) {
          loadingInstance.close()
          if(res.data.code === 200) {
            this.ruleForm.datas = res.data.data.customer_complaint

            if(this.ruleForm.datas) {
              this.ruleForm.datas.forEach(val => {
                val.status = false
                if(!val.selectStatus) {
                  val.selectStatus = ''
                }
              })
            }

            this.ruleForm.periodDatas = res.data.data.period

            this.ruleForm.periodDatas.forEach(val => {
              val.status = false
              if(!val.selectStatus) {
                val.selectStatus = ''
              }
            })

            this.ruleForm.bugDatas = res.data.data.bug
            // let bool2 = this.ruleForm.bugDatas[0].audit_result.is_used_pms.value
            // bool2 == true ? this.sys2 = '是' : this.sys2 = '否'
            this.ruleForm.bugDatas.forEach(val => {
              val.status = false
              if(!val.selectStatus) {
                val.selectStatus = ''
              }
            })
            this.ruleForm.releaseData = res.data.data.release
            // let bool3 = this.ruleForm.releaseData[0].audit_result.is_used_release.value
            // bool3 == true ? this.sys3 = '是' : this.sys3 = '否'
            if(this.ruleForm.releaseData) {
              this.ruleForm.releaseData.forEach(val => {
                val.status = false
                if(!val.selectStatus) {
                  val.selectStatus = ''
                }
              })
            }
            this.ruleForm.imporveData = res.data.data.improve_score
            if(this.ruleForm.imporveData) {
              this.ruleForm.imporveData.forEach(val => {
                val.status = false
                if(!val.selectStatus) {
                  val.selectStatus = ''
                }
              })
            }
            this.ruleForm.pointDatas = res.data.data.point_data
            this.ruleForm.pointDatas.forEach(val => {
              val.status = false
            })

            // this.$nextTick(() => {
            //   console.log(this.$refs.myTab)
            // })
            if(this.ruleForm.datas) {
              this.activeName = '0'
            } else if(!this.ruleForm.datas && this.ruleForm.periodDatas) {
              this.activeName = '1'
            } else if(!this.ruleForm.datas && !this.ruleForm.periodDatas && this.ruleForm.bugDatas) {
              this.activeName = '2'
            } else if(!this.ruleForm.datas && !this.ruleForm.periodDatas && !this.ruleForm.bugDatas && this.ruleForm.releaseData) {
              this.activeName = '3'
            } else if(!this.ruleForm.datas && !this.ruleForm.periodDatas && !this.ruleForm.bugDatas && !this.ruleForm.releaseData && this.ruleForm.imporveData) {
              this.activeName = '4'
            } else {
              this.activeName = '5'
            }
            if(active) {
              this.init()
            }
          }
        }
      })
    },
    groupInitData() {
      this.$axios.get(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/group/data?groupId=${this.dataChoose.selectId}&time=${this.dataChoose.time}`, {headers: getHeader()})
      .then(res => {
        if(res.status === 200) {
          if(res.data.code === 200) {
            this.ruleForm.groupImporveData = res.data.data.improve_score

            this.ruleForm.groupImporveData.forEach(val => {
              val.status = false
              if(!val.selectStatus) {
                val.selectStatus = ''
              }
            })
          }
        }
      })
    },
    totalSubmit() {
      let data = []
      this.ruleForm.tableData.forEach(val => {
        if(val.status) {
          data.push(val)
        }
      })
      if (!data.length) {
        this.$message({
          showClose: true,
          message: '请先选择要录入的选项!',
          type: 'error'
        })
        return
      }

      if(this.error) {
        this.$message({
          showClose: true,
          message: '您有选项填写错误请检查!',
          type: 'error'
        })
        return
      }

      this.$axios.post(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/data?projectId=${this.dataChoose.projectId}&time=${this.dataChoose.time}`, data, {headers: getHeader()})
      .then(res => {
        if(res.status === 200) {
          if(res.data.code === 200) {
            this.$message({
              showClose: true,
              message: '录入成功!',
              type: 'success'
            })
            this.ruleForm.tableData.forEach((val, index) => {
              if(val.status) {
                if(this.ruleForm.tableCurrent > 1) {
                  val.status = false
                  this.$set(this.ruleForm.tableData,  index + this.ruleForm.tableSize*(this.ruleForm.tableCurrent - 1), val)
                } else {
                  val.status = false
                  this.$set(this.ruleForm.tableData, index, val)
                }
              }
            })
          } else {
            this.$message({
              showClose: true,
              message: res.data.msg,
              type: 'error'
            })
          }
        }
      })
    },
    newSubmit(data, time) {
      this.$axios.post(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/group/data?groupId=${this.dataChoose.selectId}&time=${time}`, data, {headers: getHeader()})
      .then(res => {
        if(res.status === 200) {
          if(res.data.code === 200) {
            this.newSuccess = true
            this.$message({
              showClose: true,
              message: '录入成功!',
              type: 'success'
            })
            if(this.newSuccess) {
              this.newReload()
            }
          } else {
            this.$message({
              showClose: true,
              message: res.data.msg,
              type: 'error'
            })
          }
        }
      }).finally(() => {
        this.newSuccess = false
      })
    },
    submit(data, time) {
      this.$axios.post(`${process.env.VUE_APP_KANBAN_HOST}/api/indicator/examine/entry/data?projectId=${this.dataChoose.projectId}&time=${time}`, data, {headers: getHeader()})
      .then(res => {
        // console.log(res)
        if(res.status === 200) {
          if(res.data.code === 200) {
            this.success = true
            this.$message({
              showClose: true,
              message: '录入成功!',
              type: 'success'
            })
            if(this.success) {
              this.reload(true)
            }

          } else {
            this.$message({
              showClose: true,
              message: res.data.msg,
              type: 'error'
            })
          }
        }
      }).finally(() => {
        this.success = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '../assets/common/common.scss';
  /deep/ .el-table th.gutter{
    display: table-cell!important;
  }
  /deep/ .disabled-row{
    background: #F5F7FA;
  }
  #supplementWrapper{
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;
  }
  #supplementWrapper >>> .el-table .cell{
    padding: 0;
  }
  #supplementWrapper >>> .el-table--medium td{
    padding: 0;
  }
  #point >>>  .el-table--medium td, #improve >>>  .el-table--medium td, #newimprove >>>  .el-table--medium td{
    padding: 10px 0;
  }
  .red{
    color: #F56C6C;
  }
  .log{
    position: relative;
    top: -105px;
    left: -20px;
    float: right;
  }
  .border{
      box-sizing: content-box;
      height: 0;
      overflow: visible;
      margin-top: 1rem;
      margin-bottom: 1rem;
      border: 0;
      border-top: 1px solid rgba(0,0,0,.1);
  }
  .borders{
    border-bottom: 1px solid #dfe6ec;
  }

  .primary{
      color: #409EFF;
      font-size: 30px;
      margin-top: 20px;
      margin-bottom: 10px;
      font-weight: 400;
  }
  .bgColor{
      background: #fff;
  }
  .pad{
      padding: 0 20px;
      padding-top: 20px;
  }
  .marT{
      margin-top: 20px;
  }
</style>
